URLRewrite problem (seems it continues rewriting in spite of [L])
It seems very simple, but I'm already about knocking my head against
walls.
I want urls like "http://host/dir/blabla" to be rewritten to
"http://host/dir/script.php?param=blabla"
The following .htaccess is put into /dir/
---- .htaccess ---
RewriteEngine On
RewriteRule ^(.*)$ script.php?param=$1 [L]
-----------------------
The script.php ( in /dir/) gets "param" as "script.php".
If I use something like
RewriteRule ^([^s].*)$ script.php?param=$1 [L]
the engine works as I want.
So, what's up?
Thank you!
Re: URLRewrite problem (seems it continues rewriting in spite of [L])
"rr" <anatoly.rr [at] gmail.com> schreef in bericht
news:1165424677.534833.121310 [at] 80g2000cwy.googlegroups.com...
> I want urls like "http://host/dir/blabla" to be rewritten to
> "http://host/dir/script.php?param=blabla"
>
> The following .htaccess is put into /dir/
> RewriteEngine On
> RewriteRule ^(.*)$ script.php?param=$1 [L]
>
> The script.php ( in /dir/) gets "param" as "script.php".
>
> If I use something like
> RewriteRule ^([^s].*)$ script.php?param=$1 [L]
> the engine works as I want.
>
> So, what's up?
Your destination after rewrite is in the same folder, either
put it elsewhere or exclude it from the rewrite:
RewriteCond %{SCRIPT_URL} !/script\.php$
RewriteRule (.*) script.php?param=$1 [L]
HansH
Re: URLRewrite problem (seems it continues rewriting in spite of [L])
rr wrote:
> It seems very simple, but I'm already about knocking my head against
> walls.
>
> I want urls like "http://host/dir/blabla" to be rewritten to
> "http://host/dir/script.php?param=blabla"
An internal redirect is performed after a URL rewrite, which will
re-execute all of the rules in .htaccess causing infinite recursion. I
like to check if a status variable is set and be done. Also you don't
need the end-of-line anchor since regexps are greedy by default.
RewriteCond %{ENV:REDIRECT_ISDONE} =""
RewriteRule ^(.*) script.php?param=$1 [E=ISDONE:1,L]
--Randall